package com.example.chapter13;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;

/*
 * 13.3.案例实施-追加内容到文件
 * */
public class FileAppendExample {
    public static void main(String[] args) {
        String filePath = "path/to/your/file.txt";
        String contentToAppend = "\nThis is appended content.";
        Path path = Paths.get(filePath);
        try {
            Files.write(path, contentToAppend.getBytes(), StandardOpenOption.APPEND);
            System.out.println("Content appended successfully");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
